package com.example.service.impl;

import com.example.dao.OrdersMapper;
import com.example.entity.Orders;
import com.example.service.OrdersService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;

@Service
public class OrdersServiceImpl implements OrdersService {
    @Resource
    OrdersMapper ordersMapper;

    @Override
    public PageInfo<Orders> queryAll(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        ArrayList<Orders> ordersList = ordersMapper.queryAll();
        PageInfo<Orders> pageInfo = new PageInfo<>(ordersList);
        return pageInfo;
    }

    @Override
    public int deleteById(Integer id) {
        return ordersMapper.deleteById(id);
    }

    @Override
    public Orders findById(Integer id) {
        return ordersMapper.findById(id);
    }

    @Override
    public int update(Orders orders) {
        return ordersMapper.update(orders);
    }

    @Override
    public int insert(Orders orders) {
        return ordersMapper.insert(orders);
    }

}
